#include "Cube.h"

Cube::Cube()
  : mSize(1.0), mPosition(0.0, 0.0, 0.0),
    mRotX(0.0), mRotY(0.0), mRotZ(0.0)
{}

Cube::Cube(const QVector3D &pos, float size, float rx, float ry, float rz)
  : mSize(size), mPosition(pos), mRotX(rx), mRotY(ry), mRotZ(rz)
{}

float Cube::size() const { return mSize; }
void Cube::setSize(float size) { mSize = size;}
const QVector3D& Cube::pos() const { return mPosition; }
void Cube::setPos(const QVector3D &pos) { mPosition = pos; }

void Cube::create()
{
 // mDisplayListID = glGenLists(1);
 // glNewList(mDisplayListID, GL_COMPILE);
    glBegin(GL_QUADS);
      // Top
      glNormal3f(0, 1, 0);
      glVertex3f(-1, 1, -1);
      glVertex3f(1, 1, -1);
      glVertex3f(1, 1, 1);
      glVertex3f(-1, 1, 1);

      // Bottom
      glNormal3f(0, -1, 0);
      glVertex3f(-1, -1, -1);
      glVertex3f(1, -1, -1);
      glVertex3f(1, -1, 1);
      glVertex3f(-1, -1, 1);

      // Left
      glNormal3f(1, 0, 0);
      glVertex3f(1, -1, -1);
      glVertex3f(1, 1, -1);
      glVertex3f(1, 1, 1);
      glVertex3f(1, -1, 1);

      // Right
      glNormal3f(-1, 0, 0);
      glVertex3f(-1, -1, -1);
      glVertex3f(-1, 1, -1);
      glVertex3f(-1, 1, 1);
      glVertex3f(-1, -1, 1);

      // Back
      glNormal3f(0, 0, -1);
      glVertex3f(-1, -1, -1);
      glVertex3f(1, -1, -1);
      glVertex3f(1, 1, -1);
      glVertex3f(-1, 1, -1);

      // Front
      glNormal3f(0, 0, 1);
      glVertex3f(-1, -1, 1);
      glVertex3f(1, -1, 1);
      glVertex3f(1, 1, 1);
      glVertex3f(-1, 1, 1);
    glEnd();
  //glEndList();
}

void Cube::render()
{
  create();
  /*
  if (glIsList(mDisplayListID))
  {
    glScalef(mSize,mSize,mSize);
    glCallList(mDisplayListID);
  }
  */
}
